#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct apple
{
    int x, y;
    apple(int _x, int _y) : x(_x), y(_y) {}
};
vector<apple> num;
bool compare(apple &a, apple &b)
{
    return a.y < b.y;
}
int main()
{
    int n, s, a, b;
    cin >> n >> s >> a >> b;
    int t = a + b;
    while (n--)
    {
        int x, y;
        cin >> x >> y;
        num.push_back(apple(x, y));
    }
    sort(num.begin(), num.end(), compare);
    int k = 0;
    for (auto &p : num)
    {
        if (p.x <= t)
        {
            s -= p.y;
            if (s < 0)
            {
                break;
            }
            k++;
        }
    }
    cout << k << endl;
    return 0;
}